package com.xy.biz.base.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.base.domain.bo.ExpressBO;
import com.xy.biz.base.domain.po.ExpressPO;
import com.xy.biz.base.domain.query.ExpressQuery;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.base.domain.resp.GetExpressResponse;
import com.xy.biz.base.domain.req.SaveExpressRequest;
import com.xy.biz.base.domain.req.ListExpressRequest;

/**
 * 
 * 
 * @author zgy
 * @date 2021-9-17
 */
public class ExpressConverter {
	
	public static ExpressPO toPO(ExpressBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ExpressPO(), true);
	}
	
	public static List<ExpressPO> toPO(Collection<ExpressBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExpressPO(), true);
	}
	
	public static ExpressBO fromPO(ExpressPO source) {
		return BeanUtilsEx.copyProperties(source, () -> new ExpressBO());
	}
	
	public static List<ExpressBO> fromPO(Collection<ExpressPO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExpressBO());
	}
	
	public static ExpressBO toBO(SaveExpressRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new ExpressBO(), true);
	}
	
	public static List<ExpressBO> toBO(Collection<SaveExpressRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new ExpressBO(), true);
	}
	
	public static GetExpressResponse toResponse(ExpressBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetExpressResponse());
	}
	
	public static List<GetExpressResponse> toResponse(Collection<ExpressBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetExpressResponse());
	}
	
	public static ExpressQuery toQuery(ListExpressRequest source) {
		if(null == source) {
			return null;
		}
		ExpressQuery target = new ExpressQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
